import json


class VideoMessage:

    def __init__(self, video_files, channel, video_title, graph_path, video_desc, video_url, tag_str, dynamic_str):
        self.video_files = video_files
        self.channel = channel
        self.video_title = video_title
        self.graph_path = graph_path
        self.video_desc = video_desc
        self.video_url = video_url
        self.tag_str = tag_str
        self.dynamic_str = dynamic_str

    @classmethod
    def dict2Video(cls, d):
        return VideoMessage(d['video_files'], d['channel'], d['video_title'], d['graph_path'], d['video_desc'],
                            d['video_url'], d['tag_str'], d['dynamic_str'])

    def toJson(self):
        return json.dumps(obj=self.__dict__, ensure_ascii=False)


def MessagefromJson(json_str) -> VideoMessage:
    return json.loads(json_str, object_hook=VideoMessage.dict2Video)
